﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.IO;

namespace RecommenderSystem
{
    class Program
    {

        static void Assignment4()
        {
            int features = 5;
            double splitRatio = 0.90;
            List<string> lMethods = new List<string>();

            lMethods.Add("Pearson");
            lMethods.Add("Cosine");
            lMethods.Add("SVD");
            lMethods.Add("DT");
            lMethods.Add("BasicDT");

            List<int> lLengths = new List<int>();

            lLengths.Add(5);
            lLengths.Add(10);
            lLengths.Add(15);
            lLengths.Add(25);
            lLengths.Add(30);
            lLengths.Add(40);


            RecommenderSystem rs = new RecommenderSystem();
            rs.Load("MovieLens/u.data", splitRatio);
            rs.TrainBaseModel(features);

            rs.ComputeRMSEAndSaveToFile(lMethods, "RmseResult");

            //           Console.ReadLine();
            //            lMethods.Add("DT");
            /*
			lMethods.Add("NNPearson");
            lMethods.Add("NNCosine");
            lMethods.Add("NNSVD");
            lMethods.Add("CP");
            lMethods.Add("Popularity");
			*/



            //Compute Presion and recall
            Console.WriteLine("computing precision & recall");
            DateTime dtStart = DateTime.Now;
            Dictionary<int, Dictionary<string, Dictionary<string, double>>> dResults = rs.ComputePrecisionRecallAndSaveToExl(lMethods, lLengths, "PrecisionAndRecallResults");
            Console.WriteLine("Execution time was " + Math.Round((DateTime.Now - dtStart).TotalSeconds, 0));
            Console.WriteLine("computing hit ratio");
            dtStart = DateTime.Now;
            Dictionary<string, double> hrs = rs.ComputeHitRatio(lMethods);
            Console.WriteLine("Execution time was " + Math.Round((DateTime.Now - dtStart).TotalSeconds, 0));

            foreach (string key in hrs.Keys)
            {
                Console.Out.WriteLine(key + " : " + hrs[key]);
            }
            Console.WriteLine("bye.");
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Assignment4();
        }
    }
}
